home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Tool Chest / Testing & Debugging / Virtual User tools / SPEC S&L v.1.0.1 / Libraries / TargetCheck.Lib < prev    next >
Encoding:
Text File  |  1993-12-17  |  5.4 KB  |  144 lines  |  [TEXT/MPS ]

  1. #
  2. # ****************************************************************************
  3. #
  4. #    File Name:        TargetCheck.Lib
  5. #
  6. #    Contains:    xxx put contents here xxx
  7. #
  8. #    Written by:    Kevin Avoy, Ken Landreth, Michael Leong, Gil Spencer et al
  9. #
  10. #    Copyright:    © 1993 by Apple Computer, Inc., all rights reserved.
  11. #
  12. # ****************************************************************************
  13. #            C h a n g e        H i s t o r y (most recent first):
  14. # ****************************************************************************
  15. #
  16. #        Vers      Date        Author        Description
  17. #        ----    --------    ------    ---------------------------------------------
  18. #     <1.0.6>     9/29/93    KTA        Removed TargetCheck(), OpenCDEV(which), CloseCDEV(which),
  19. #                                    SwitchAddressing(value) SwitchVM(state), SwitchFS(state),
  20. #                                    SwitchCache(state) because there were buggy and no one
  21. #                                    was(could) using them
  22. #     <1.0.5>     8/25/93    KTA        TargetCheck() - BugFix where turning VM off wasn't handled
  23. #                                    properly.
  24. #     <1.0.4>     7/15/93    KTA        Updated References to tasks in Gestalt.lib whos names were
  25. #                                    changed. Took out code to turn VM down - SwitchVM().  Took out
  26. #                                    releasetarget prior to restart if restartNecessary -
  27. #                                    TargetCheck().  Removed checks for Undef, before checking state.
  28. #     <1.0.3>      6/8/93    NAGA    Unmark tasks that are not published
  29. #     <1.0.2>     5/21/93    NAGA    Adding header and porting old files to follow new standards
  30. #
  31. # ****************************************************************************
  32. #
  33.  
  34. ########################################################################
  35. #                            External libraries 
  36. #=======================================================================
  37. Libraries 'Output.Lib';
  38.  
  39. #########################################################################
  40. #                            Restart()
  41. #========================================================================
  42. # Author:        Rick Violet
  43. # Description:    Restarts and reaquires Targets
  44. # Parameters:    None
  45. # Returns:        1 - Success
  46. #                0 - Failure
  47. # Examples:        Restart();
  48. # Assumptions:    None 
  49. #========================================================================
  50. # History:
  51. # KTA    7/14/93     Changed some of the logging and added global restartNecessary := 0;
  52. #########################################################################
  53. TASK Restart() begin
  54.     global gLogLevel;
  55.     No_Error := 0;
  56.     Target_Not_Found := 3; #error codes returned by acquireTarget/releaseTarget
  57.     Target_Failure := 1;   #error codes returned by acquireTarget/releaseTarget
  58.     Time_to_restart := 7; #Approximate time(in seconds) it might take for a
  59.                           #Mac to restart
  60.  
  61.     match[target t:?target_name z:?target_zone];    # Get the target name and zone through unification
  62.     global restartNecessary := 0;
  63.  
  64.     Select[MenuItem t:'Restart' m:[menu t:"Special"]]!;    # Select the Restart MenuItem
  65.     if (gLogLevel >= 3) 
  66.     begin
  67.         println "Selected the 'Restart' menu item";
  68.         Println "Rebooting CPU";
  69.     end;
  70.  
  71.     # Need a save document dialog handler
  72.     
  73.     result := releaseTarget();                # Release target so VU realizes that the target has been lost. 
  74.  
  75.     if (result <> Target_Failure)            # Released okay
  76.     begin
  77.         if (gLogLevel >= 5) 
  78.             Println "Released target successfully";
  79.  
  80.         wait(Time_to_restart);                # Short wait to allow machine to boot.
  81.         
  82.         #do an acquire with the same old target name and zone address
  83.         result := acquireTarget(target_name, target_zone);
  84.         
  85.         while(result = Target_Not_Found)    # Keep trying until target is found or some other error is reported
  86.         begin
  87.             result := acquireTarget(target_name, target_zone);
  88.             wait(Time_to_restart - 2); # Wait one more time
  89.         end;
  90.         if (result = No_Error)                # Reaquired target successfully
  91.         begin
  92.                                             # Need to wait till all inits get loaded.
  93.             while not match[menu];            # Match menu may not be a long enough wait
  94.             LogStr("Reaquired target successfully",4);
  95.             return (1);
  96.         end; 
  97.         else                                # Couldn't reaquire target successfully
  98.         begin
  99.             LogStr("!@#$% Couldn't aquire target",1);
  100.             return (0);
  101.         end;
  102.     end;#if released ok
  103.     else
  104.     begin
  105.         LogStr("!@#$% Couldn't release target",1);
  106.         return(0);                                 #error couldn't release target
  107.     end;
  108. end; # Restart()
  109.  
  110.  
  111. #########################################################################
  112. #                     MatchApplication(logMe,UpdateAppTitle)
  113. #========================================================================
  114. # Author:            KTA
  115. # Description:        This routine will match the current Application and,
  116. #                    if the logMe parameter is 1, will log the current
  117. #                    application name by passing it to LogStr().  If a
  118. #                    parameter is not passed, the default behavior will
  119. #                    log the application's title.  This routine will also
  120. #                    set the global gAppTitle to the application's title.
  121. #                    Output appears in the following format:
  122. #                            The current application is "Finder"
  123. # Parameters:        logMe - 1 to print the current application's title
  124. #                            0 not to print the application's title
  125. #                    UpdateAppTitle     - 1 to update the global AppTitle
  126. #                                    - 0 not to update global AppTitle
  127. # Return Value:        string holding current application's title
  128. # Examples:            MatchApplication();
  129. # Assumptions:        there is an active application
  130. #========================================================================
  131. # History:
  132. #
  133. #########################################################################
  134. TASK MatchApplication(logMe := 1, UpdateAppTitle :=1) 
  135. begin
  136.     match[application t:?theAppTitle];
  137.     if (UpdateAppTitle)
  138.         global gAppTitle := theAppTitle;            #to Verify App
  139.  
  140.     if (logMe)
  141.         LogStr("The current application is '{theAppTitle}'");
  142.  
  143.     return(theAppTitle);
  144. end; # MatchApplication()